//生成路由表和路由器。配置路由相关信息
import { createRouter,createWebHistory } from "vue-router";
import OrderTab from "@/views/OrderTab.vue";
import ProductTab from "@/views/ProductTab.vue";
import UserTab from "@/views/UserTab.vue";
import { createWebHashHistory } from "vue-router";
import ProductDetails from "@/views/ProductDetails.vue";
//路由，从哪里来到哪里去（重点是到哪里去
//路由==》路由表==》路由器

//路由表
const routes=[
    {
        path:"/order",
        name:"order",
        component: OrderTab
    },
    {
        path:"/product",
        name:"product",
        component: ProductTab,
        children:[
            {
                path:"details/:id?/:title?/:des?",// :id?
                name:"details",
                component:ProductDetails
            }
        ]
    },
    {
        path:"/user",
        name:"user",
        component: UserTab
    }
]

//创建路由器
const router=createRouter({
    //工作模式
    history:createWebHistory(),
    //HISTORY模式（这种模式下，把前段的这个项目部署到服务器(阿里云的云服务器-就看做普通电脑)，必须在服务端做配置

    //地址栏会有#
    // history:createWebHashHistory(),//地址栏会有#，这种模式下不用在服务端配置
    routes// routes:routes
})
export default router